<?php

namespace App\Http\Controllers\Car;

use App\Helpers\ResponseData;
use App\Http\Controllers\Controller;
use App\Models\Car\ActivePrice;
use Illuminate\Http\Request;

// 活动折扣
class ActivePriceController extends Controller
{
    use ResponseData;
    public function index(ActivePrice $model,Request $request){
        $size = $request->input('size',10);
        $data = $model->orderBy('id','desc')
            ->paginate($size);
        return $this->success($data);
    }
    public function store(ActivePrice $model,Request $request){
        $data = $request->all();
        $model->fill($data);
        $model->save();
        return $this->success('保存成功');
    }
    public function edit(ActivePrice $model,Request $request){
        $data = $model->find($request->id);
        return $this->success($data);
    }
    public function update(ActivePrice $model,Request $request){
        $data = $model->find($request->id);
        $map = $request->all();
        $data->update($map);
        return $this->success('修改成功');
    }
    public function destory(ActivePrice $model,Request $request){
        $data = $model->find($request->id);
        $data->delete();
    }
}
